<?php
  // no direct access
  defined( '_JEXEC' ) or die( 'Restricted access' );
  jimport( 'joomla.application.component.view');
  
  class PersonViewPerson extends JView
  {              
    var $_name = "person";
  
    function display()
    { 
      $this->displayList();
    }
    
    function displayList()
    {
      /* sorting */
      $state =& $this->get( 'state' );
            $lists['order_Dir'] = $state->get($this->_name . 'filter_order_Dir');
            $lists['order']     = $state->get($this->_name . 'filter_order');
            $this->assignRef('lists', $lists);    
      
      $person   = $this->getModel();
      $this->assign('persons', $person->get(null,true));
      
      $pagination = $this->get('Pagination');
      $this->assign('pagination', $pagination);
      
      JToolBarHelper::title( JText::_( 'Persons' ), 'generic.png' );
      
      JToolBarHelper::publishList();
      JToolBarHelper::unpublishList();
      JToolBarHelper::addNew();
      JToolBarHelper::editList();
      JToolBarHelper::deleteList();
      
      PBNYHelper::createMenu();
      
      parent::display("list");    
    }
    
    function displayAdd()
    {      
      $person   = $this->getModel('person');
      JToolBarHelper::title( JText::_( 'Add Person' ), 'generic.png' );
      JToolBarHelper::save();
      JToolBarHelper::cancel();  

      parent::display("edit");
    }    
    
    function displayEdit()
    {    
      $person   = $this->getModel();
      $cids = JRequest::getVar('cid', null, 'default', 'array' );
      
      if($cids === null)
          JError::raiseError(500, 'cid parameter missing from the request');
      
      $person_obj = $person->get($cids[0]);
      $this->assign('person', $person_obj);
      
      JToolBarHelper::title( JText::_( 'Edit Person' ), 'generic.png' );
      JToolBarHelper::save();
      JToolBarHelper::cancel();  

      parent::display("edit");
    }    
  }
?>